home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
pcr
/
pcr4_4.lha
/
DIST
/
debugnub
/
CirioNubProcs2.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-04-16
|
3KB
|
149 lines
/* begincopyright
Copyright (c) 1988-1989 Xerox Corporation. All rights reserved.
Use and copying of this software and preparation of derivative works based
upon this software are permitted. Any distribution of this software or
derivative works must comply with all applicable United States export
control laws. This software is made available AS IS, and Xerox Corporation
makes no warranty about the software, its performance or its conformity to
any specification. Any person obtaining a copy of this software is requested
to send their name and post office or electronic mail address to:
PCR Coordinator
Xerox PARC
3333 Coyote Hill Rd.
Palo Alto, CA 94304
endcopyright */
/*
* CirioNubProcs2.c
*
* Demers, November 2, 1989 10:29:11 am PST
*/
#include "xr/CirioNubProtocol.h"
#include "xr/CirioNubMarshall.h"
#include "xr/CirioNubProcs.h"
#include "xr/CirioNubEnvironment.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
CirioNubRetCode
CirioNubServeOpenPath(argc, args)
int argc;
unsigned *args;
{
int fd;
CirioNubRetCode ans;
if( argc != 1 )
return(cnrc_badArgs);
fd = open(args[0], O_RDONLY, 0);
if( fd < 0 ) fd = (-errno);
if( (ans = CirioNubPutInt32(fd)) != cnrc_ok )
return ans;
return cnrc_ok;
}
CirioNubRetCode
CirioNubServeCloseFile(argc, args)
int argc;
unsigned *args;
{
int closeAns;
CirioNubRetCode ans;
if( argc != 1 )
return(cnrc_badArgs);
closeAns = close(args[0]);
if( closeAns < 0 ) closeAns = (-errno);
if( (ans = CirioNubPutInt32(closeAns)) != cnrc_ok )
return ans;
return cnrc_ok;
}
CirioNubRetCode
CirioNubServeLSeekFile(argc, args)
int argc;
unsigned *args;
{
int seekAns;
CirioNubRetCode ans;
if( argc != 3 )
return(cnrc_badArgs);
seekAns = lseek(args[0], args[1], args[2]);
if( seekAns < 0 ) seekAns = (-errno);
if( (ans = CirioNubPutInt32(seekAns)) != cnrc_ok )
return ans;
return cnrc_ok;
}
CirioNubRetCode
CirioNubServeReadFile(argc, args)
int argc;
unsigned *args;
{
int len, readAns;
CirioNubRetCode ans;
# ifndef MAXREADFILELEN
# define MAXREADFILELEN 2048
# endif
char buf[MAXREADFILELEN];
if( argc != 2 )
return(cnrc_badArgs);
if( (len = args[1]) > MAXREADFILELEN )
return(cnrc_badArgs);
readAns = read(args[0], buf, args[1]);
if( readAns >= 0 ) {
if( (ans = CirioNubPutInt32(readAns)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutBlock8(buf, readAns)) != cnrc_ok )
return ans;
} else {
if( (ans = CirioNubPutInt32(-errno)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutBlock8(buf, 0)) != cnrc_ok )
return ans;
}
return cnrc_ok;
}
CirioNubRetCode
CirioNubServeStatPath(argc, args)
int argc;
unsigned *args;
{
int statAns;
CirioNubRetCode ans;
struct stat statBuf;
if( argc != 1 )
return(cnrc_badArgs);
statBuf.st_mtime = 0;
statBuf.st_size = 0;
statAns = stat(args[0], &statBuf);
if( statAns < 0 ) statAns = (-errno);
if( (ans = CirioNubPutInt32(statAns)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutCard32(statBuf.st_mtime)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutCard32(statBuf.st_size)) != cnrc_ok )
return ans;
return cnrc_ok;
}